package com.blackbox.price.configuration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: TWQ
 * @Description:
 * @Date: Created in 下午 22:47 2020/8/13 0024
 * @Modidied By: NO
 */
@Configuration
public class BlackBoxFilter implements Filter {
    Logger logger = LoggerFactory.getLogger(BlackBoxFilter.class);

    public void init(FilterConfig filterConfig) throws ServletException {
        logger.info("filter :{} ", filterConfig.getServletContext());
    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;

        //logger.info("BlackBoxFilter :{} ", request.getRequestURI());
        //执行
        filterChain.doFilter(servletRequest, servletResponse);
    }

    public void destroy() {

    }
}
